import { Body, Controller, Post } from '@nestjs/common';
import { ProductService } from './product.service'
import { QueryProductVo } from "../../vo/product/query-product.vo";
import { ApiBasicAuth, ApiExtraModels, ApiOperation, ApiTags } from "@nestjs/swagger";
import { QueryDetailReqVo } from 'src/vo/product/query-detail-req.vo';
import { ProductEntity } from './product.entity';
import { ApiResult } from 'src/decorators/api-result.decorator';
import { ResultVo } from 'src/vo/common/result.vo';
@ApiExtraModels(
    ProductEntity,
    ResultVo
)

@Controller('product')
@ApiTags('商品管理')
@ApiBasicAuth("token")
export class ProductController {
    constructor(private readonly productService: ProductService) { }

    @Post("queryProductsByPage")
    @ApiOperation({ summary: '分页获取商品列表接口' })
    @ApiResult(ProductEntity, true, true)
    async queryProductsByPage(@Body() queryProductVo: QueryProductVo) {
        return await this.productService.queryProductsByPage(queryProductVo);
    }

    @Post("queryDetail")
    @ApiOperation({ summary: '查询商品详情' })
    @ApiResult(ProductEntity)
    async queryDetail(@Body() queryDetailReqVo: QueryDetailReqVo) {
        return await this.productService.queryDetail(queryDetailReqVo);
    }
}
